import os

from dotenv import load_dotenv
from openai import OpenAI

if __name__ == '__main__':
    load_dotenv(override=True)
    DASHSCOPE_API_KEY = os.getenv("DASHSCOPE_API_KEY")
    client = OpenAI(api_key=DASHSCOPE_API_KEY, base_url="https://dashscope.aliyuncs.com/compatible-mode/v1")
    # print(client.models.list())
    completion = client.chat.completions.create(model="qwen-plus",
                                                messages=[
                                                    {"role": "system",
                                                     "content": "你是一个乐于助人的助手，请根据用户的问题给出回答"},
                                                    {"role": "user", "content": "你好，请介绍一下你自己"}
                                                ])
    print(completion.model_dump_json(exclude_none=True, indent=2))
